package me.stephenj.experiment2.controller;

import me.stephenj.experiment2.model.Person;
import me.stephenj.experiment2.service.PersonsService;
import me.stephenj.experiment2.utils.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class PersonController {
    @Autowired
    PersonsService personsService;

    @RequestMapping(value = "/persons", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    public String getPersons() {
        List<Person> persons = personsService.getPersons();
        return JSONResult.fillResultString(200, "", persons);
    }
}
